import {productionPrdNoticeGet} from "../../../../api";
import {formatDate} from "../../../../utils/jk-utils";

export default {
	data() {
		return {

		};
	},
	methods: {
		getNoticeDetailRequest(code) {
			return productionPrdNoticeGet({ code });
		},
		transferData(data) {
			let cpData = JSON.parse(JSON.stringify(data));
			let resData = cpData.productOrderBatchItem ? JSON.parse(JSON.stringify(cpData.productOrderBatchItem)) : {};
			const str = resData.coarseSandList ? resData.coarseSandList.filter(x => x.typeName === '粗纱').map(x => x.productName).join(' ; ') : '';
			resData.ingredient = str;
			resData.innerBagList = resData.innerBagList ? resData.innerBagList : [];
			resData.outerBagList = resData.outerBagList ? resData.outerBagList : [];
			resData.bundleList = resData.bundleList ? resData.bundleList : [];
			resData.coarseSandList = resData.coarseSandList ? resData.coarseSandList : [];
			resData.paperTubeList = resData.paperTubeList ? resData.paperTubeList : [];
			this.$set(resData, 'productId', cpData.orderIssued.order.productId);
			this.$set(resData, 'productCode', cpData.orderIssued.order.productCode);
			this.$set(resData, 'productName', cpData.orderIssued.order.productName);
			this.$set(resData, 'categoryId', cpData.categoryId);
			this.$set(resData, 'categoryCode', cpData.categoryCode);
			this.$set(resData, 'categoryName', cpData.categoryName);

			this.$set(resData, 'customerId', cpData.orderIssued.order.customerId);
			this.$set(resData, 'customerCode', cpData.orderIssued.order.customerCode);
			this.$set(resData, 'customerName', cpData.orderIssued.order.customerName);

			this.$set(resData, 'workshopId', cpData.workshopId);
			this.$set(resData, 'workshopCode', cpData.workshopCode);
			this.$set(resData, 'workshopName', cpData.workshopName);
			this.$set(resData, 'belongDate', formatDate(Date.now()));
			this.$set(resData, 'code', cpData.code);
			this.$set(resData, 'packingPlanId', cpData.id);
			this.$set(resData, 'packingPlanCode', cpData.code);
			this.$set(resData, 'remark', resData.packageRemark);
			return resData;
		},
		/*transferData(res) {
			let resData = JSON.parse(JSON.stringify(res));
			const str = resData.coarseSandList ? resData.coarseSandList.filter(x => x.typeName === '粗纱').map(x => x.productName).join(' ; ') : '';
			resData.ingredient = str;
			this.$set(resData, 'productId', resData.order.productId);
			this.$set(resData, 'productCode', resData.order.productCode);
			this.$set(resData, 'productName', resData.order.productName);
			this.$set(resData, 'categoryId', resData.order.categoryId);
			this.$set(resData, 'categoryCode', resData.order.categoryCode);
			this.$set(resData, 'categoryName', resData.order.categoryName);

			this.$set(resData, 'customerId', resData.order.customerId);
			this.$set(resData, 'customerCode', resData.order.customerCode);
			this.$set(resData, 'customerName', resData.order.customerName);

			this.$set(resData, 'workshopId', resData.order.workshopId);
			this.$set(resData, 'workshopCode', resData.order.workshopCode);
			this.$set(resData, 'workshopName', resData.order.workshopName);
			this.$set(resData, 'code', resData.order.code);
			delete resData.order;
			delete resData.coarseSandList;

			// productOrderBatchItem

			return resData;
		},*/
	}
}
